# -*- coding: utf-8 -*-
# All Rights Reserved 
# @Time    : 2023/10/2321:52
# @Author  : Small Fu
# @Email   : 2737454073@qq.com
# @File    : req_fwq.py
__author__ = 'Small Fu'

import random

import schedule
import requests, time
from apscheduler.schedulers.blocking import BlockingScheduler


def log_token(dd):
    headers = {
        "Accept": "application/json, text/plain, */*",
        "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
        "Authorization": "Bearer null",
        "Cache-Control": "no-cache",
        "Connection": "keep-alive",
        "Content-Type": "application/json",
        "Origin": "https://mx16.com",
        "Pragma": "no-cache",
        "Referer": "https://mx16.com/",
        "Sec-Fetch-Dest": "empty",
        "Sec-Fetch-Mode": "cors",
        "Sec-Fetch-Site": "same-site",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 Edg/118.0.2088.61",
        "sec-ch-ua": "^\\^Chromium^^;v=^\\^118^^, ^\\^Microsoft",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "^\\^Windows^^"
    }
    url = "https://api.mx16.com/app/user/login"
    data = {"phone": dd['a'], "code": "", "type": "pwd", "password": dd['b']}
    response = requests.post(url, headers=headers, json=data)
    print(response.json())
    return response.json()["body"]["token"]


# headers = {
#     "Accept": "application/json, text/plain, */*",
#     "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
#     "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiMTgxNTcwMjQ0NzUzODE3NiIsInBob25lIjoiMTc2NzAzNDQ2NDQifSwiaWF0IjoxNjk4MDY5MTg0LCJleHAiOjE3MTM2MjExODR9.WZ6VdV_UXTn82KFQRaMpzmvACZn8DjDmyD3Z37AkBtE",
#     "Cache-Control": "no-cache",
#     "Connection": "keep-alive",
#     "Origin": "https://mx16.com",
#     "Pragma": "no-cache",
#     "Referer": "https://mx16.com/",
#     "Sec-Fetch-Dest": "empty",
#     "Sec-Fetch-Mode": "cors",
#     "Sec-Fetch-Site": "same-site",
#     "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 Edg/118.0.2088.61",
#     "sec-ch-ua": "^\\^Chromium^^;v=^\\^118^^, ^\\^Microsoft",
#     "sec-ch-ua-mobile": "?0",
#     "sec-ch-ua-platform": "^\\^Windows^^"
# }
# url = 'https://api.mx16.com/app/serverNests/getFreeRecord'
# response = requests.post(url, headers=headers, json=data)
#
# print(response.text)
# print(response)
'''
curl "https://api.mx16.com/app/serverNests/getGames" ^
  -H "Accept: application/json, text/plain, */*" ^
  -H "Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6" ^
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiMTgxNTcwMjQ0NzUzODE3NiIsInBob25lIjoiMTc2NzAzNDQ2NDQifSwiaWF0IjoxNjk4MDY5MTg0LCJleHAiOjE3MTM2MjExODR9.WZ6VdV_UXTn82KFQRaMpzmvACZn8DjDmyD3Z37AkBtE" ^
  -H "Cache-Control: no-cache" ^
  -H "Connection: keep-alive" ^
  -H "Origin: https://mx16.com" ^
  -H "Pragma: no-cache" ^
  -H "Referer: https://mx16.com/" ^
  -H "Sec-Fetch-Dest: empty" ^
  -H "Sec-Fetch-Mode: cors" ^
  -H "Sec-Fetch-Site: same-site" ^
  -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 Edg/118.0.2088.61" ^
  -H "sec-ch-ua: ^\^"Chromium^\^";v=^\^"118^\^", ^\^"Microsoft Edge^\^";v=^\^"118^\^", ^\^"Not=A?Brand^\^";v=^\^"99^\^"" ^
  -H "sec-ch-ua-mobile: ?0" ^
  -H "sec-ch-ua-platform: ^\^"Windows^\^"" ^
  --compressed
  
  
  
curl "https://api.mx16.com/app/serverNests/getEggs?id=13" ^
  -H "Accept: application/json, text/plain, */*" ^
  -H "Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6" ^
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiMTgxNTcwMjQ0NzUzODE3NiIsInBob25lIjoiMTc2NzAzNDQ2NDQifSwiaWF0IjoxNjk4MDY5MTg0LCJleHAiOjE3MTM2MjExODR9.WZ6VdV_UXTn82KFQRaMpzmvACZn8DjDmyD3Z37AkBtE" ^
  -H "Cache-Control: no-cache" ^
  -H "Connection: keep-alive" ^
  -H "Origin: https://mx16.com" ^
  -H "Pragma: no-cache" ^
  -H "Referer: https://mx16.com/" ^
  -H "Sec-Fetch-Dest: empty" ^
  -H "Sec-Fetch-Mode: cors" ^
  -H "Sec-Fetch-Site: same-site" ^
  -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 Edg/118.0.2088.61" ^
  -H "sec-ch-ua: ^\^"Chromium^\^";v=^\^"118^\^", ^\^"Microsoft Edge^\^";v=^\^"118^\^", ^\^"Not=A?Brand^\^";v=^\^"99^\^"" ^
  -H "sec-ch-ua-mobile: ?0" ^
  -H "sec-ch-ua-platform: ^\^"Windows^\^"" ^
  --compressed

'''
Authorization = [

]


def get_qd():
    headers = {
        "Accept": "application/json, text/plain, */*",
        "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
        "Authorization": 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiMTgxNTcwMjQ0NzUzODE3NiIsInBob25lIjoiMTc2NzAzNDQ2NDQifSwiaWF0IjoxNjk4MDY5MTg0LCJleHAiOjE3MTM2MjExODR9.WZ6VdV_UXTn82KFQRaMpzmvACZn8DjDmyD3Z37AkBtE',
        "Cache-Control": "no-cache",
        "Connection": "keep-alive",
        "Content-Type": "application/json",
        "Origin": "https://mx16.com",
        "Pragma": "no-cache",
        "Referer": "https://mx16.com/",
        "Sec-Fetch-Dest": "empty",
        "Sec-Fetch-Mode": "cors",
        "Sec-Fetch-Site": "same-site",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 Edg/118.0.2088.61",
        "sec-ch-ua": "^\\^Chromium^^;v=^\\^118^^, ^\\^Microsoft",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "^\\^Windows^^"
    }
    url = "https://api.mx16.com/app/serverNests/receiveFreeServer"
    timestamp = time.strftime("%m%d%H", time.localtime())  # 年月日_时分秒
    data = [{"serverName": f'{timestamp}_wdsj', "gameId": 1, "eggId": "15"},
            {"serverName": f'{timestamp}_jh', "gameId": 8, "eggId": "93"}]
    data = random.choice(data)
    # data = {"serverName": f'{timestamp}_wdsj', "gameId": 1, "eggId": "15"}  # java 专用
    # data = {"serverName": f'{timestamp}_jh', "gameId": 8, "eggId": "93"}  # 饥荒
    response = requests.post(url, headers=headers, json=data, verify=False)
    print(response.text, data)


scheduler = BlockingScheduler()

scheduler.add_job(get_qd, 'cron', hour=8, minute=20)
scheduler.add_job(get_qd, 'cron', hour=9, minute=20)
scheduler.add_job(get_qd, 'cron', hour=10, minute=20)
scheduler.add_job(get_qd, 'cron', hour=11, minute=20)
scheduler.add_job(get_qd, 'cron', hour=12, minute=20)
scheduler.add_job(get_qd, 'cron', hour=13, minute=20)
scheduler.add_job(get_qd, 'cron', hour=14, minute=20)
scheduler.add_job(get_qd, 'cron', hour=15, minute=20)
scheduler.add_job(get_qd, 'cron', hour=16, minute=20)
scheduler.add_job(get_qd, 'cron', hour=17, minute=20)
scheduler.add_job(get_qd, 'cron', hour=18, minute=20)

if __name__ == '__main__':
    for i in [

    ]:
        Authorization.append(
            log_token(i)
        )
    print(Authorization)
    while True:
        schedule.run_pending()
        timestamp = time.strftime("%Y%m%d_%H%M%S", time.localtime())  # 年月日_时分秒
        print(timestamp)
        time.sleep(1)
